package at.ac.lbg.media.vis.client.theme.view
{
	import mx.collections.ArrayCollection;
	
	public class Category {
		
		public var id:Number;
		public var name:String;
		public var parent:Category;
		public var index:int;
		public var isSelected:Boolean;
		// if false: this is a keyword
		public var isCategory:Boolean;
		public var num:int;
		public var countArtworks:int;
		public var children:ArrayCollection;
		// the index of the render function to render the icon shape
		// see PetalLibrary. Correlates with countArtworks:
		// the higher countArtworks the lower is the index.
		public var iconIndex:int;
		
		public function Category(obj:Object) { 
			super();
			if (obj) {
				id = obj.id;
				name = obj.name;
				if (obj.countArtworks) {
					countArtworks = obj.countArtworks / 2.67;
				}
				if (obj.parent != null) {
					parent = new Category(obj.parent);
				}
				if (obj.children != null) {
					children = new ArrayCollection();
					for (var i:int = 0; i < obj.children.length; i++) {
						children.addItem(new Category(obj.children[i]));
					}
					isCategory = true;
				}
			}

		}

	}
}